<?php
require_once '../../includes/global.php';
echo <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>更新数据</title>
</head>
<body>

<div style="color:#5ab437;margin-top:20px;margin-left:10px;">
<img src="../../images/working.gif" />
Now,prod date updatting.It will be take you a few time ...
</div>

EOT;

$cleardate="TRUNCATE TABLE `lm_prod_v`";	//清楚数据

$update="
insert into lm_prod_v 
select * 
from lm_psv
";
!$_REQUEST['op']&&$_REQUEST['op']='update';
switch ($_REQUEST['op']){
	case 'update':
		Dz("TRUNCATE TABLE `lm_prod_v`");	//清空表格			
		echo <<<EOT
			<div style="font-size:13px;margin-top:3px;margin-left:30px;">Clean the old table <span style="color:#5ab437;">complete ...</span></div>
EOT;
		Dz("insert lm_prod_v(parentid,title) select parentid,title from lm_prodsort where del!=1");		//载入最新数据	分类
		echo <<<EOT
			<div style="font-size:13px;margin-top:3px;margin-left:30px;">Date move  <span style="color:#5ab437;">complete ...</span></div>
EOT;
		$allsort=Dgs('prod_v'," parentid!=-1 and parentid!=1 ");
		foreach ($allsort as $key=>$value){
			try {
				$p_num_tmp=Dz("select count(*) as num from lm_prod where del!=1  and sortid='".$value['id']."' ");
				//Jc($p_num_tmp);	//this for test the value.
				Dz("update lm_prod_v set pnum='".$p_num_tmp[0]['num']."' where id='".$value['id']."' limit 1");
			echo <<<EOT
			<div style="font-size:13px;margin-top:3px;margin-left:30px;">The $value[id]  lm_prod_v of table,<span style="color:#5ab437;">complete ...</span></div>
EOT;
			}catch (Exception $e){
				Ja('数据清除错误,请与管理员联系');
				exit;
			}
		}
		break;
	default:
		die("请从正常的通道进入,否则可能");
		break;
}
echo <<<EOT
<div style="margin-top:10px;margin-left:80px;">The all be <span style="color:#5ab437;">complete !</span></div>
EOT;

echo <<<EQT
</body>
</html>
EQT;
?>